package com.jackeys.piaems.configuration;

import com.jackeys.piaems.filter.JwtTokenInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import java.util.Arrays;

/**
 * @ClassName: JwtWebMvcConfiguration
 * @Description: 配置jwt拦截器
 * @Author: Jackeys
 * @Date: 2021-06-19 15:04
 * @Version: 1.0
 */

@Configuration
public class JwtWebMvcConfiguration implements WebMvcConfigurer {
    @Autowired
    private JwtTokenInterceptor authorizationInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //配置所有路径都要经过jwt拦截器
        registry.addInterceptor(authorizationInterceptor).addPathPatterns("/**")
                .excludePathPatterns(Arrays.asList("/", "/refresh"));
    }
}
